#ifndef _W25Q_H
#define _W25Q_H

#include "stm32f4xx.h"
#include "spi.h"

#define W25Q_CS_0  HAL_GPIO_WritePin(F_CS_GPIO_Port, F_CS_Pin , GPIO_PIN_RESET)
#define W25Q_CS_1  HAL_GPIO_WritePin(F_CS_GPIO_Port, F_CS_Pin , GPIO_PIN_SET)

#define W25Q_WRITE_ENABLE    0x06
#define W25Q_WRITE_DISABLE   0x04
#define W25Q_CHIP_ERASE      0xc7
#define W25Q_READ_STATUS_REG1 0x05
#define W25Q_READ_STATUS_REG2 0x35
#define W25Q_READ_STATUS_REG3 0x15
#define W25Q_PAGE_WRITE       0x02
#define W25Q_PAGE_READ       0x03

void W25Q_Init(void);
void W25Q_Page_Write(uint32_t addr, uint8_t* pBuf, uint16_t num);
void W25Q_Page_Read(uint32_t addr, uint8_t* pBuf, uint16_t num);



void W25Q_WriteBytes(uint8_t *data, uint8_t num);
void W25Q_ReadBytes(uint8_t *data, uint8_t num);
uint8_t W25Q_ReadWrite(uint8_t tx_data);
uint16_t W25Q_ReadDevId(void);
void W25Q_WriteEnable();
void W25Q_WriteDisable();
void W25Q_Chip_Erase();
void W25Q_Wait_Busy();



uint8_t Read_Status_Register(uint8_t cmd);
#endif